<template>
  <div>
    <zh-form  :span="8" ref="formInfo" :colmun="1"  :labelCol="labelColBase"
              :wrapperCol="wrapperColBase" :rules="rules" :model="formInfo"  labelAlign="right" >

      <zh-card title="基本信息" style="width:100%">
        <zh-row>
          <zh-input
              prop="h2114"
              type="select"
              label="区划"
              :options="dictData.xzqh"
              :defaultFields="{ label: 'dictValue', value: 'dictKey' }"
              v-model="formInfo.h2114"
          ></zh-input>
          <zh-input
              prop="h2102"
              type="text"
              label="编号"
              v-model="formInfo.h2102"
          ></zh-input>
          <zh-input
              prop="h2103"
              type="text"
              label="详情位置"
              v-model="formInfo.h2103"
          ></zh-input>
          <zh-input
              prop="h2104"
              type="text"
              label="发掘尺寸"
              v-model="formInfo.h2104"
          ></zh-input>
          <zh-input
              prop="h2105"
              type="text"
              label="结构特点"
              v-model="formInfo.h2105"
          ></zh-input>
          <zh-input
              prop="h2106"
              type="select"
              label="保护级别"
              :options="dictData.b0105"
              :defaultFields="{ label: 'dictValue', value: 'dictKey' }"
              v-model="formInfo.h2106"
          ></zh-input>
          <zh-input
              prop="h2107"
              type="text"
              label="文物价值"
              v-model="formInfo.h2107"
          ></zh-input>
          <zh-input
              prop="h2108"
              type="text"
              label="保护状况"
              v-model="formInfo.h2108"
          ></zh-input>
          <zh-input
              prop="h2109"
              type="text"
              label="巡查文保员"
              v-model="formInfo.h2109"
          ></zh-input>
<!--          <zh-input
              prop="h2109"
              type="select"
              label="巡查文保员"
              :options=this.patrolPersonList
              :defaultFields="{ label: 'fullName', value: 'userId' }"
              v-model="formInfo.h2109"
          ></zh-input>-->
          <zh-input
              prop="h2111"
              type="text"
              label="点位负责人"
              v-model="formInfo.h2111"
          ></zh-input>
<!--          <zh-input
              prop="h2111"
              type="select"
              label="点位负责人"
              :options=this.pointPersonList
              :defaultFields="{ label: 'fullName', value: 'userId' }"
              v-model="formInfo.h2111"
          ></zh-input>-->
          <zh-input
              prop="h2113"
              type="text"
              label="三维超链接"
              v-model="formInfo.h2113"
          ></zh-input>
        </zh-row>
      </zh-card>
    </zh-form>
  </div>
</template>

<script>
import modal from 'ant-design-vue/es/modal'
import {getBatchDict} from "@/services/system/api"
import {ancientWharfAdd,getAncientWharfDetails,getPatrolAndPointPerson} from '@/services/system/whdngxlApi'
import {TreeSelect} from "ant-design-vue";
import moment from "moment";
import {mapGetters} from "vuex";

const SHOW_PARENT = TreeSelect.SHOW_PARENT;
export default {
  name: "CulturalFileAddForm",
  components:{
  },
  computed: {
    ...mapGetters(['size']),
  },
  props:{
    listQuery:{
      type:Function,
      default:null
    },
  },
  data() {
    return {
      toolbarConfig: {
        slots: {
          tools: 'toolbar_tools'
        }
      },
      formInfo:{
        h2101:'',
        h2102:'',
        h2103:'',
        h2104:'',
        h2105:'',
        h2106:'',
        h2107:'',
        h2108:'',
        h2109:'',
        h2111:'',
        h2113:'',
        h2114:'',
      },
      rules:{},
      dictData: {
        xzqh:[],
        b0105:[],
      },
      taskAreaTree:[],
      SHOW_PARENT,
      labelCol: { span: 2 },
      wrapperCol: { span: 22 },
      labelColBase: {
        xs: {span: 24},
        sm: {span: 8},
      },
      wrapperColBase: {
        xs: {span: 24},
        sm: {span: 16},
      },
      patrolPersonList:[],//巡查文保员下拉集合
      pointPersonList:[],//点位负责人下拉集合
    }
  },

  created() {
    const params2 = {};
    params2.dictFields = "xzqh,b0105";
    this.$http.post(getBatchDict, params2).then((res) => {
      this.dictData = res.result;
    });

  /*  this.$http.post(getPatrolAndPointPerson, {}).then((res) => {
      this.patrolPersonList = res.result.patrolPersonList
      this.pointPersonList = res.result.pointPersonList
    });*/
  },
  methods: {
    initData(data){
      //编辑
      if(data.h2101){
        const params = {}
        params.h2101 = data.h2101
        setTimeout(() => {
          this.$http.post(getAncientWharfDetails, params).then((res) => {
              this.formInfo = res.result
          }).catch((error) => {
          }).finally(() =>{
          })
        }, 50)
      }
    },
    confirm(){
      if(this.formInfo.h2114 == '' || this.formInfo.h2114 == null ){
        modal.warn({ title: "提示", content: "区划不能为空" });
        return;
      }
      if(this.formInfo.h2102 == '' || this.formInfo.h2102 == null ){
        modal.warn({ title: "提示", content: "编号不能为空" });
        return;
      }
      this.$loading.show('正在处理数据,请等待...')
      const params = Object.assign(this.formInfo)
      setTimeout(() => {
        this.$http.post(ancientWharfAdd, params).then((res) => {
          this.$message.info('保存成功')
            this.$emit("handleCancel")
            if(this.listQuery) {
              this.listQuery()
            }
        }).catch((error) => {
          console.log(JSON.stringify(error))
        }).finally(() =>{
          this.$loading.hide()
        })
      }, 50)
    },
  }
}
</script>

<style scoped lang="less">
.list-item {
  display: flex;

  .list-item-index {
    width: 36px;
    font-size: 18px;
  }
}

.sub-form {
  margin-top: 15px;
}
</style>
